package com.itheima.web.controller;

import com.itheima.service.db.UserYear;
import com.itheima.vo.UsersVo;
import com.itheima.web.manager.AnalysisManager;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class AnalysisController {

    @Autowired
    AnalysisManager analysisManager;


    //获取首页统计数据
    @GetMapping("/dashboard/summary")
    public ResponseEntity findSummaryVo(){

        return analysisManager.findSummaryVo();
    }

    //折线图
    @GetMapping("/dashboard/users")
    public ResponseEntity users(@RequestParam String sd,@RequestParam(defaultValue = "0") String ed,@RequestParam(defaultValue = "1")String type){

        Date startTime = new Date(Long.parseLong(sd));
        Date endTime = new Date(Long.parseLong(ed));

        return analysisManager.users(startTime,endTime,type);

    }
}
